package com.itheima.reggie.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.reggie.pojo.Setmeal;
import com.itheima.reggie.pojo.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface SetmealDishDao extends BaseMapper<SetmealDish> {

    @Insert("insert into setmeal_dish values (null,#{setmealId},#{dishId},#{name},#{price},#{copies},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    void save(SetmealDish setmealDish);

    @Delete("delete from setmeal_dish where setmeal_id=#{setmealId}")
    void deleteByid(Long setmealId);

    @Select("SELECT * FROM setmeal_dish s INNER JOIN dish d ON s.dish_id = d.id WHERE setmeal_id = #{setmealId}")
    List<Map<String,Object>> findSetmealDish(Long setmealId);

    @Select("SELECT * FROM setmeal_dish where setmeal_id = #{setmealId}")
    List<SetmealDish> findSetmealDishGl(Long setmealId);
}
